<!--菜单：能耗预警中的
月份能耗预警-->
<template>
    <div class="MonthWarn">
        <!--        存放筛选条件-->
        <el-row class="top">
            <el-col :span="3.5">
                <div class="grid-content bg-purple box-left">
                    <span>月份：</span>
                    <div class="block" style="display: inline">
                        <el-date-picker
                                align="right"
                                type="date"
                                v-model="Mydate"
                                size="mini"
                                style="width: 150px"
                                placeholder="选择日期"
                        >
                        </el-date-picker>
                    </div>
                </div>
            </el-col>
            <el-col :span="3.5">
                <div class="grid-content bg-purple-light box-mid-left">
                    <span>与前 </span>
                    <el-input-number class="avg" size="small" v-model="num" controls-position="right"  :min="1"></el-input-number>
                    <span> 月平均值比较   </span>
                </div>
            </el-col>
            <el-col :span="4">
                <div class="grid-content bg-purple box-mid">
                    <span>预留百分比： </span>
                    <el-input-number class="percent" size="small" v-model="avg" controls-position="right" :min="1" step="0.01"></el-input-number>
                </div>
            </el-col>
            <el-col :span="2">
                <div class="grid-content bg-purple-light box-mid-right">
                    <el-button size="mini" class="btn" @click="searchMsg" plain>查询</el-button>
                </div>
            </el-col>
            <el-col :span="2">
                <div class="grid-content bg-purple-light box-right">
                    <el-button size="mini" class="btn" plain>导出</el-button>
                </div>
            </el-col>
        </el-row>
        <div class="bottom">
            <el-table
                    :data="tableMonthData"
                    :cell-style="{textAlign:'center',padding:'0'}"
                    style="width: 100%"
                    :default-sort = "{prop: 'date', order: 'descending'}"
                    :header-cell-style="{backgroundColor:'#F5F8FF',textAlign:'center',padding:'0'}"
                    height="460px"
                    border
            >
                <el-table-column
                        prop="id"
                        label="#"
                        sortable
                        width="150px">
                </el-table-column>
                <el-table-column
                        prop="table_id"
                        label="表号"
                        sortable
                        style="text-align: center"
                        width="270px">
                </el-table-column>
                <el-table-column
                        prop="name"
                        label="名称"
                        sortable
                        width="150px">
                </el-table-column>
                <el-table-column
                        prop="start_end_date"
                        label="起结时间"
                        sortable>
                </el-table-column>
                <el-table-column
                        prop="enc"
                        label="能耗"
                        sortable
                        width="190px">
                </el-table-column>
                <el-table-column
                        prop="consult"
                        label="参考"
                        sortable
                        width="200px">
                </el-table-column>
                <el-table-column
                        label="是否超标"
                        width="200px"
                >
                    <div class="slot"></div>
                </el-table-column>
            </el-table>
        </div>
    </div>

    <!--        存放数据-->

</template>

<script>
    export default {
        name: "MonthWarn",
        data(){
            return{
                Mydate:'',
                num:3,
                avg:10.00,
                tableMonthData: [],
            }
        },
        mounted(){
            this.queryMonthConsumption();
        },
        methods:{
            queryMonthConsumption(){
                this.axios.get('/api/module8/MonthCons').then(resp=>{
                    this.tableMonthData=resp.data.list;
                })
            },
            searchMsg(){
                if(!this.Mydate||!this.num||!this.avg){
                    this.$message.error('输入信息不能为空');
                }else{
                    this.axios.get('/api/module8/Monthsearch',{
                        params:{
                            Mydate: this.Mydate,
                            num: this.num,
                            avg: this.avg
                        }
                    }).then(resp=>{
                        this.tableMonthData=resp.data.list;
                    })
                }
            }
        }
    }
</script>

<style scoped>
    .MonthWarn{
        width: 100%;
        /*height: 492px;*/
        flex: 1;
        overflow-x: scroll;
        display: flex;
        flex-direction: column;
    }
    .top{
        width: 100%;
        height: 9%;
    }
    .bottom{
        width: 100%;
        height: 91%;
    }
    .el-col{
        position: relative;
        top: 7px;
    }
    /*    日期*/
    .box-left{
        margin-left: 10px;
        font-size: 12px;

    }
    /*平均值比较*/
    .box-mid-left{
        margin-left: 10px;
        font-size: 12px;
    }
    .box-mid{
        margin-left: 20px;
        font-size: 12px;
    }
    /*    平均值的框*/
    .avg{
        width: 90px;
    }
    /*    百分比*/
    .percent{
        width: 100px;
    }
    /*    按钮*/
    .btn{
        width: 100px;
        height: 30px;
    }

    .slot{
        border-radius: 50%;
        width: 10px;
        height: 10px;
        background-color: #CA180B;
        margin: 0 auto;
    }
    .el-table {
        height: 100% !important;
    }
    .el-table th {
        padding: 0px 0px;
        color: black;
        font-size: 12px;
        height: 10px!important;
    }
    .el-table__body tr,
    .el-table__body td {
        padding: 0px 0px;
        height: 10px;
        line-height: 30px;
    }
    .el-table_4_column_23{
        text-align: center!important;
    }

</style>
